package com.sunlands.zlcx.usercenter.service;

import com.sunlands.zlcx.usercenter.domain.UsersLearnTimingDO;
import com.sunlands.zlcx.usercenter.repository.UsersLearnTimingRepository;
import com.sunlands.zlcx.usercenter.util.BeanPropertiesUtil;
import com.sunlands.zlcx.usercenter.vo.count.LearnTimeChartVO;
import com.sunlands.zlcx.usercenter.vo.count.LearnTimeOverView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public class UsersLearnTimingService implements BeanPropertiesUtil {

    @Autowired
    private UsersLearnTimingRepository usersLearnTimingRepository;

    /**
     * 根据时间统计各个学内容时长
     * @param startTime startTime
     * @param endTime endTime
     * @return List<LearnTimePieVO>
     */
    public List<LearnTimeChartVO> countByLearnContent(Long userId, Date startTime, Date endTime) {

        return usersLearnTimingRepository.countByLearnContent(userId, startTime, endTime);
    }


    /**
     * 根据日期统计计时时长
     * @param startTime startTime
     * @param endTime endTime
     * @return List<LearnTimePieVO>
     */
    public List<LearnTimeChartVO> countByDay(Long userId, Date startTime, Date endTime) {

        return usersLearnTimingRepository.countByDay(userId, startTime, endTime);
    }

    /**
     * 根据日期统计计时时长
     * @param startTime startTime
     * @param endTime endTime
     * @return List<LearnTimePieVO>
     */
    public List<LearnTimeChartVO> countByMonth(Long userId, Date startTime, Date endTime) {

        return usersLearnTimingRepository.countByMonth(userId, startTime, endTime);
    }

    public List<UsersLearnTimingDO> listByDate(Long userId, Date startTime, Date endTime) {
        return usersLearnTimingRepository.listByDate(userId, startTime, endTime);
    }

    public LearnTimeOverView countByUserId(Long userId, Date startTime, Date endTime) {
        return usersLearnTimingRepository.countByUserId(userId, startTime, endTime);
    }
}

